package com.cn.learn.starter.config;

import com.cn.learn.starter.service.ITimeService;
import com.cn.learn.starter.service.impl.TimeServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName TimeServiceConfig
 * @Description TODO
 * @Author JiJiang
 * @Date 2023/7/5 18:39
 * @Version 1.0
 */
@Configuration
@ComponentScan(basePackages = {"com.cn.learn.starter"})
@ConditionalOnClass(value = {ITimeService.class, TimeServiceImpl.class})
public class TimeServiceConfig {

    @Bean
    @ConditionalOnMissingBean
    public ITimeService timeService() {

        System.out.println("开始创建 TimeServiceImpl 的实例对象！！！！");

        return new TimeServiceImpl();
    }

}
